


package Conexion;
import Conexion.Conexion;
import java.sql.*;

public class Listado_Beneficiarios_x_Cotizante
{
	private String cedulacotizante;
	 
    Conexion con;
    
    public static String cad="";
    
      
    public Listado_Beneficiarios_x_Cotizante() {
    }

    public String getCedulacotizante()
    {
    	return cedulacotizante;
    }
    
    public void setCedulacotizante(String cedulacotizante)
    {
    	this.cedulacotizante = cedulacotizante;
    }
    
    
    public Listado_Beneficiarios_x_Cotizante(String cedulacotizante)
    {
      this.cedulacotizante=cedulacotizante;
    }


//**********************************************************************************+


    public void mostrar() throws Exception
    {
        
       cad= " ";          
       con = new Conexion();
       con.ConexionPostgres(); 
       
       String sql="select * from cotizante where cedulacotizante='"+this.getCedulacotizante()+"'";
       ResultSet rs = con.consultar(sql);
        
       String pn ="";
       String pa =""; 
       if(rs.next())
       {

         pn= rs.getString("primernombrecotizante");
         pa= rs.getString("primerapellidocotizante");
       }
       
              
       cad+="<HTML><HEAD><TITLE>Objeto Window</TITLE></HEAD>";
       cad+="<BODY>";
       cad+="<SCRIPT LANGUAGE =\"JavaScript\">";
       cad+=" var miVentana; ";
       cad+="miVentana=open(\"\",\"miVentana\",\"menubar=0,width=600,height=200,top=100,left=100\");";
       cad+="miVentana.document.write(\"<HTML>\");";
       cad+="miVentana.document.write(\"<HEAD>\");";
       cad+="miVentana.document.write(\"<TITLE>Mensaje Enviado</TITLE>\");";
       cad+="miVentana.document.write(\"</HEAD>\");";
       cad+="miVentana.document.write(\"<BODY>\");";
       cad+="miVentana.document.write(\"<CENTER>\");";
       
       cad+="miVentana.document.write(\"<H3>  Listado de  Beneficiarios segun Cotizante  \");";
       cad+=" miVentana.document.write(\" .<BR>\");";
       
       cad+=" miVentana.document.write(\" CEDULA DEL COTIZANTE No. " + this.getCedulacotizante() + "<BR>\");";
       
       cad+=" miVentana.document.write(\"<H3> NOMBRE DEL COTIZANTE No. " + pn + " " + pa + "<BR>\");";
       
       cad+="miVentana.document.write(\"<FORM>\");";
       cad+="miVentana.document.write(\"<table width=463 border=1 cellspacing=10>\");";
       cad+="miVentana.document.write(\"<tr> <td width=77>CEDULA BENEFICIARIO </td> <td width=68>PRIMER NOMBRE</td><td width=77>PRIMER APELLIDO </td>\");";
       cad+="miVentana.document.write(\"<td width=59>TELEFONO </td><td width=68>DIRECCION</td><td width=121>PARENTEZCO</td>\");";
       cad+="miVentana.document.write(\"</tr>\");";      
             
    
       sql="select * from beneficiario where cedulacotizante='" +this.getCedulacotizante() + "'";
       rs = con.consultar(sql);
        
        while(rs.next())
        {
           
           cad+="miVentana.document.write(\"<TR>\");";
           cad+="miVentana.document.write(\"<TD>"+rs.getString("cedulabeneficiario")+"</TD>\");";
	       cad+="miVentana.document.write(\"<TD>"+rs.getString("primernombrebeneficiario")+"</TD>\");";
	       cad+="miVentana.document.write(\"<TD>"+rs.getString("primerapellidobeneficiario")+"</TD>\");";
	       cad+="miVentana.document.write(\"<TD>"+rs.getString("telefonobeneficiario")+"</TD>\");";
	       cad+="miVentana.document.write(\"<TD>"+rs.getString("direccionbeneficiario")+"</TD>\");";
	       cad+="miVentana.document.write(\"<TD>"+rs.getString("parentezcocotizante")+"</TD>\");";
	       
	       cad+="miVentana.document.write(\"</TR>\");";
         
         }
         
           cad+="miVentana.document.write(\"</TABLE>\");";
	   
                   
       cad+="miVentana.document.write(\"</FORM>\");";
       cad+=" miVentana.document.write(\"</CENTER>\");";
       cad+="miVentana.document.write(\'<INPUT TYPE=BUTTON VALUE=\"Cerrar\" onClick=\"self.close()\">\');";
       cad+="miVentana.document.write(\"</BODY>\"); ";
       cad+="miVentana.document.write(\"</HTML>\");";
       cad+="</SCRIPT>";
       cad+="</BODY></HTML>";
           
       Archivo ar= new Archivo();
       ar.crear_archivo("webapps/citasmedicaspolicia/paginas/listado_beneficiarios_x_cotizante.html",cad);
	       
	           
       
   }     
     
                      
       //**************************************************************************************
           
    
}
